package io.renren.wechat.controller;

import io.renren.common.utils.R;
import io.renren.wechat.service.department.DepartmentService;
import io.renren.wechat.service.domain.Department;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 部门管理
 */
@RestController
@RequestMapping("/wechat/dept")
public class DepartmentController {
    private static final Logger LOGGER = LoggerFactory.getLogger(DepartmentController.class);
    private DepartmentService departmentService;


    @RequestMapping("/list")
    public R list(@RequestParam(name = "deptId", required = false) Integer departmentId,
                  @RequestParam(name = "corpId") String corpId) {
        final List<Department> list = departmentService.list(corpId, departmentId);
        LOGGER.debug("query by deptId:[{}] list: {}", departmentId, list);

        return R.ok().put("list", list);
    }


    @Autowired
    public void setDepartmentService(DepartmentService departmentService) {
        this.departmentService = departmentService;
    }
}
